<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no">
  <title>{$tdk['title']}</title>
  <meta name="description" content="{$tdk['description']}">
  <meta name="keywords" content="{$tdk['keywords']}">
  <meta name="author" content="alonez"/>
  <meta name="baidu-site-verification" content="code-mjNnJHp6FK" />
  <link rel="shortcut icon" href="https://ujia-img.oss-cn-shenzhen.aliyuncs.com/beauthome/favicon.ico">
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
  <script src="https://res.bestyoujia.com/common/third/jquery.cookie.js"></script>
  <script src="https://ujia-res.oss-cn-shenzhen.aliyuncs.com/changehome/assets/js/layer-v3.1.1/layer.js"></script>
  <link href="https://cdn.bootcss.com/animate.css/3.7.2/animate.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.1/style/weui.min.css"/>
  <style>
    /*html,body {*/
    /*  background: url(https://ujia-img.oss-cn-shenzhen.aliyuncs.com/web/2019act/popularization1214/mobile/bg.png) no-repeat center center fixed;*/
    /*  background-size: cover;*/
    /*}*/

    ::-moz-placeholder {
      color: #ccc;
    }

    ::-webkit-input-placeholder {
      color: #ccc;
    }

    :-ms-input-placeholder {
      color: #ccc;
    }

    ol, ul {
      list-style: none;
    }

    p {
      margin: 0;
    }

    .img-fit {
      display: block;
      max-width: 100%;
      height: auto;
    }

    .show {
      display: block;
    }

    .hide {
      display: none;
    }

    .style-container, .room-container, .furniture-container, .order-container {
      display: flex;
      width: 100%;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }

    .content{
      width: 92%;
      display: flex;
      margin-top: .3rem;
      flex-wrap: wrap;
    }
    .content > .item{
      /*width: calc(calc(100% / 3) - 10px);*/
      width: calc(100% / 3);
      margin-top: .3rem;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      position: relative;
    }

    .content > .item > img {
      width: 80%;
    }

    .content > .item > .check-img {
      position: absolute;
      width: .4rem;
      height: .4rem;
      right: .35rem;
      top: 1.43rem;
    }

    .content > .item > p {
      color: #BC9552;
      font-size: .3rem;
      font-weight: bold;
      margin-top: .2rem;
    }

    .next {
      width: 2.6rem;
      height: .8rem;
      margin-top: .8rem;
      border: none;
      background: rgba(215,66,67,1);
      border-radius: .35rem;
      font-size: .36rem;
      color: #ffffff;
    }

    .header {
      padding-top: .7rem;
    }

    .header > .title {
      color: #BC9552;
      font-size: .44rem;
      font-weight: bold;
      line-height: 1.5;
    }

    .header > .sub-title {
      color: #BC9552;
      font-size: .24rem;
      font-weight: 400;
      margin-top: .3rem;
    }

    .step {
      margin-top: .8rem;
    }

    .step > .title {
      color: #BC9552;
      font-size: .36rem;
      font-weight: bold;
    }

    .step > .mut-choose {
      color: #BC9552;
      font-size: .24rem;
      font-weight: 400;
    }

    button:focus {
      outline: none;
    }

    .result-container {
      position: relative;
      display: none;
    }

    .result-content {
      width: 100%;
      height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
    }

  </style>
  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?40c4a0b79991b779265eef34e4be9d02";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>
</head>
<body>
<div class="container" style="text-align: center;background: url(https://ujia-img.oss-cn-shenzhen.aliyuncs.com/web/2019act/popularization1214/mobile/bg.png) no-repeat center center;background-size: cover;height: 100vh;">

  <div class="header">
    <p class="title">
      提前算一算
      <br>
      全屋家具软装整配需要多少钱？
    </p>
    <p class="sub-title"><span style="font-size: .15rem;margin: .05rem">◆</span>2021最新全屋软装整配报价方案，4步轻松获取<span style="font-size: .15rem;margin: .05rem">◆</span></p>
  </div>

  <div class="furniture-container">
    <div class="step">
      <p class="title">第一步，请选择您需要的家具</p>
      <p class="mut-choose">（可多选）</p>
    </div>
    <div class="content">
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/3_1.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>家具类</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/3_2.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>窗帘</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/3_3.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>灯具</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/3_4.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>定制柜</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/3_5.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>床垫</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/3_6.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>其他</p>
      </div>
    </div>
    <button class="next">下一步</button>
  </div>

  <div class="room-container" style="display: none">
    <div class="step">
      <p class="title">第二步，请选择您的户型</p>
    </div>
    <div class="content">
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/2_1.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>套一</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/2_2.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>套二</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/2_3.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>套三</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/2_4.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>套四</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/2_5.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>别墅</p>
      </div>
      <div class="item">
        <img class="img-fit" src="https://res.bestyoujia.com/web/ZMYJ/landing/2_6.png" alt="" />
        <img class="check-img sel" src="https://res.bestyoujia.com/web/ZMYJ/landing/sel.png" alt="" />
        <img class="check-img unsel" src="https://res.bestyoujia.com/web/ZMYJ/landing/unsel.png" alt="" />
        <p>复式</p>
      </div>
    </div>
    <div style="text-align: left;margin-top: .3rem;
    display: flex;
    flex-direction: column;">
      <div style="color: #BC9552; font-size: .3rem;font-weight: bold">输入房屋面积㎡：</div>
      <input id="area" type="number" placeholder="输入房屋面积" style="width: 4.6rem;border:1px solid rgba(153,153,153,1);
border-radius: .06rem;text-align: center;height: .7rem; font-size: .32rem;margin-top: .3rem" />
    </div>
    <button class="next" style="margin-top: .3rem">下一步</button>
  </div>

  <div class="order-container" style="display: none">
    <div class="step">
      <p class="title">第三步，获取报价和设计方案</p>
    </div>
    <div style="display: flex;
    flex-direction: column;
    align-items: center;
margin-top: .8rem">
      <div style="text-align: left;margin-top: .4rem;max-width: 4.8rem">
        <p style="color: #BC9552; font-size: .3rem;font-weight: bold;">*请输入手机号获取报价：</p>
        <input id="mobile" type="number" placeholder="输入手机号码" style="width: 4.8rem;height: .7rem; font-size: .32rem;border:1px solid rgba(153,153,153,1);
border-radius: .06rem;text-align: center;margin-top: .15rem" />
      </div>
    </div>
    <button class="next" style="width:4.8rem;margin-top: .6rem;font-size: .35rem;border-radius: 6px">立即获取报价</button>
  </div>

</div>

<section class="result-container">
<div id="close" style="position: absolute; right: .5rem">
  <img style="width: .6rem" src="https://res.bestyoujia.com/web/DGZJ/baojia/close.png" alt=""/>
</div>
<div class="result-content">
  <img style="width: 3.7rem" src="https://res.bestyoujia.com/web/ZMYJ/landing/succeed.png" alt=""/>
  <div style="
font-size: .44rem;margin-top: .48rem;
font-weight: bold;
color: #333333;">恭喜您，获取成功</div>
  <div style="margin-top: .3rem;
font-size: .26rem;
font-weight: 400;
color: #666666;">稍后会有工作人员联系您详细讲解，请留意来电！</div>

  <div style="margin-top: 1.1rem;
font-size: .36rem;
font-weight: bold;
color: #1C2857;">—— 官网专享优惠 ——</div>
  <div style="margin-top: .3rem; line-height: .8rem;
font-size: .26rem;
font-weight: 400;
color: #1C2857;">
    ①4000㎡展厅及多种风格样板间免费参观<br>

    ②精美礼品，到店免费领<br>

    ③专业设计师免费户型规划<br>

    ④专车接驾逛体验馆
  </div>
</div>
</section>

<!-- js START -->
<script src="https://res.bestyoujia.com/common/assets/js/appointment.js"></script>
<script src="https://res.bestyoujia.com/web/ZMYJ/assets/js/mobile-common.js"></script>
<script src="https://res.bestyoujia.com/web/UJGC/common/mobile/js/backTop.js"></script>
<script src="https://res.bestyoujia.com/web/UJGC/common/mobile/js/common.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script src="https://res.bestyoujia.com/common/assets/js/wxShare.js"></script>
<script type="text/javascript">
  initWxShare('提前算一算，全屋家具软装整配需要多少钱？', '2020最新全屋软装整配报价方案，4步轻松获取');

  (function (n, e) {
    const t = n.documentElement, i = "orientationchange" in window ? "orientationchange" : "resize", d = function () {
      const n = t.clientWidth;
      n && (t.style.fontSize = n / 7.5 + "px")
    };
    n.addEventListener && (e.addEventListener(i, d, !1));
    n.addEventListener && n.addEventListener("DOMContentLoaded", d, !1);
  })(document, window);

  Array.prototype.remove = function(val) {
    const index = this.indexOf(val);
    if (index > -1) {
      this.splice(index, 1);
    }
  };

  let canNext = false;
  const furnitureArr = [];
  $('.furniture-container > .content > .item').each(function(i, e){
    let isChecked = false;
    $(e).on('click', function () {
      if(isChecked) {
        isChecked = false;
        onHide($(this));
        furnitureArr.remove($(this).find('p').text());
      }else{
        isChecked = true;
        onShow($(this));
        furnitureArr.push($(this).find('p').text());
      }
      console.log('furnitureArr', furnitureArr);
    });
  });

  function onShow(e) {
    console.log('onShow', e);
    e.find('.sel').removeClass('hide');
    e.find('.unsel').removeClass('show');
    e.find('.sel').addClass('show');
    e.find('.unsel').addClass('hide');
  }

  function onHide(e) {
    console.log('onHide', e);
    e.find('.sel').removeClass('show');
    e.find('.unsel').removeClass('show');
    e.find('.unsel').removeClass('hide');
    e.find('.sel').addClass('hide');
    e.find('.unsel').addClass('show');
  }

  let room = '';
  $('.room-container > .content > .item').each(function(i, e){

    console.log(1);
    $(e).on('click', function () {
      console.log(2);
      $('.room-container > .content > .item').find('.sel').removeClass('show');
      $('.room-container > .content > .item').find('.sel').addClass('hide');
      $('.room-container > .content > .item').find('.unsel').addClass('show');
      $('.room-container > .content > .item').find('.unsel').removeClass('hide');
      onShow($(this));
      room = $(this).find('p').text();

      // if(isChecked) {
      //     isChecked = false;
      //     onHide($(this));
      //     styleArr.remove($(this).find('p').text());
      // }else{
      //     isChecked = true;
      //     onShow($(this));
      //     styleArr.push($(this).find('p').text());
      // }
      console.log('room', room);
    });
  });

  $('.next').each(function(i, e){
    $(e).on('click', function () {
      console.log('next', i);
      switch (i) {
        case 0:
          if(furnitureArr.length === 0){
            showToast('请至少选择一项家具', 1000);
            return;
          }
          $('.furniture-container').hide();
          $('.room-container').show();
          break;
        case 1:
          if(room === ''){
            showToast('请选择您的户型', 1000);
            return;
          }
          if($('#area').val() === ''){
            showToast('请输入房屋面积', 1000);
            return;
          }
          $('.room-container').hide();
          $('.order-container').show();
          break;
        case 2:
          if($('#mobile').val() === ''){
            showToast('请输入手机号码', 1000);
            return;
          }
          console.log('手机号', mobile);
          const mobile_result = validMobile($('#mobile').val());
          if(mobile_result === 0) {
            showToast('手机号格式不正确', 1000);
            return;
          }
          $('#loadingToast').fadeIn(100);

          let message = '';

          message += `户型:${room};面积:${$('#area').val()};家具:${furnitureArr.join('|')}`;

          const data = { mobile: $('#mobile').val(), housing: room, building: $('#building').val(), area: $('#area').val(), remark: message };
          doAppointment(data,
            function(res) {
             // $('#loadingToast').fadeOut();
              console.log('onAppointmentSuccess', res);
              const { data = '' } = res;
              if(data) {
                buryingPoint('APPOINTMENT', data);
                $('.container').css('display', 'none');
                $('.result-container').show();
                // setTimeout(function () {
                //   window.history.go(-1);
                // }, 1500);
              }
            }, function(err) {
              console.log('onAppointmentError', err);
              showToast('预约失败');
            });
          break;
        default:
          break;
      }
    });
  });

  $('#close').on('click', function () {
    window.history.back();
  });

  /**
   *  1:正确，0:格式错误，2:未输入
   */
  function validMobile(number) {
    var isMob = /^1\d{10}$/;
    if (number == "") {
      return 2;
    }
    return isMob.test(number) ? 1 : 0;
  }


  // $(window).scroll(function () {
  //     var a = document.getElementById("entered").offsetTop + 280;
  //     if (a >= $(window).scrollTop() && a < ($(window).scrollTop() + $(window).height())) {
  //         $("#sub").hide();
  //     } else {
  //         $("#sub").show();
  //     }
  // });

  $('#order').on('click', function () {
    const username = document.getElementById('username').value || '';
    const mobile = document.getElementById('mobile').value;
    const area = document.getElementById('area').value || '';

    if(username === '') {
      showToast('请输入您的姓名');
      return;
    }

    const mobile_result = validMobile(mobile);
    switch (mobile_result) {
      case 0:
        showToast('请输入正确的手机号');
        break;
      case 1:
        if(area === '') {
          showToast('请输入房屋面积');
          return;
        }
        $('#loadingToast').fadeIn(100);

        const data = { mobile, username, area };
        doAppointment(data,
          function(res) {
            $('#loadingToast').fadeOut();
            showToast('预约成功，我们将在2小时内联系您');
            console.log('onAppointmentSuccess', res);
            const { data = '' } = res;
            if(data) {
              buryingPoint('APPOINTMENT', data);
              document.getElementById('username').value = "";
              document.getElementById('mobile').value = "";
              document.getElementById('area').value = "";
            }
          }, function(err) {
            console.log('onAppointmentError', err);
            $('#loadingToast').fadeOut();
            document.getElementById('username').value = "";
            document.getElementById('mobile').value = "";
            document.getElementById('area').value = "";
          });
        break;
      case 2:
        showToast('请输入手机号');
        break;
    }
  });
</script>
<!-- js END -->
</body>
</html>
